//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS Forecastquery service.
///
/// Provides APIs for creating and managing Amazon Forecast resources.
public struct Forecastquery: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the Forecastquery client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "AmazonForecastRuntime",
            serviceName: "Forecastquery",
            serviceIdentifier: "forecastquery",
            signingName: "forecast",
            serviceProtocol: .json(version: "1.1"),
            apiVersion: "2018-06-26",
            endpoint: endpoint,
            variantEndpoints: Self.variantEndpoints,
            errorType: ForecastqueryErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }




    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.fips]: .init(endpoints: [
            "us-east-1": "forecastquery-fips.us-east-1.amazonaws.com",
            "us-east-2": "forecastquery-fips.us-east-2.amazonaws.com",
            "us-west-2": "forecastquery-fips.us-west-2.amazonaws.com"
        ])
    ]}

    // MARK: API Calls

    /// Retrieves a forecast for a single item, filtered by the supplied criteria. The criteria is a key-value pair. The key is either item_id (or the equivalent non-timestamp, non-target field) from the TARGET_TIME_SERIES dataset, or one of the forecast dimensions specified as part of the FeaturizationConfig object. By default, QueryForecast returns the complete date range for the filtered forecast. You can request a specific date range. To get the full forecast, use the CreateForecastExportJob operation.  The forecasts generated by Amazon Forecast are in the same timezone as the dataset that was used to create the predictor.
    @Sendable
    @inlinable
    public func queryForecast(_ input: QueryForecastRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> QueryForecastResponse {
        try await self.client.execute(
            operation: "QueryForecast", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves a forecast for a single item, filtered by the supplied criteria. The criteria is a key-value pair. The key is either item_id (or the equivalent non-timestamp, non-target field) from the TARGET_TIME_SERIES dataset, or one of the forecast dimensions specified as part of the FeaturizationConfig object. By default, QueryForecast returns the complete date range for the filtered forecast. You can request a specific date range. To get the full forecast, use the CreateForecastExportJob operation.  The forecasts generated by Amazon Forecast are in the same timezone as the dataset that was used to create the predictor.
    ///
    /// Parameters:
    ///   - endDate: The end date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00.
    ///   - filters: The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for client_21 in the electricity usage dataset, specify the following:  {"item_id" : "client_21"}    To get the full forecast, use the CreateForecastExportJob operation.
    ///   - forecastArn: The Amazon Resource Name (ARN) of the forecast to query.
    ///   - nextToken: If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours.
    ///   - startDate: The start date for the forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00.
    ///   - logger: Logger use during operation
    @inlinable
    public func queryForecast(
        endDate: String? = nil,
        filters: [String: String],
        forecastArn: String,
        nextToken: String? = nil,
        startDate: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> QueryForecastResponse {
        let input = QueryForecastRequest(
            endDate: endDate, 
            filters: filters, 
            forecastArn: forecastArn, 
            nextToken: nextToken, 
            startDate: startDate
        )
        return try await self.queryForecast(input, logger: logger)
    }

    /// Retrieves a what-if forecast.
    @Sendable
    @inlinable
    public func queryWhatIfForecast(_ input: QueryWhatIfForecastRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> QueryWhatIfForecastResponse {
        try await self.client.execute(
            operation: "QueryWhatIfForecast", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves a what-if forecast.
    ///
    /// Parameters:
    ///   - endDate: The end date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T20:00:00.
    ///   - filters: The filtering criteria to apply when retrieving the forecast. For example, to get the forecast for client_21 in the electricity usage dataset, specify the following:  {"item_id" : "client_21"}  To get the full what-if forecast, use the CreateForecastExportJob operation.
    ///   - nextToken: If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours.
    ///   - startDate: The start date for the what-if forecast. Specify the date using this format: yyyy-MM-dd'T'HH:mm:ss (ISO 8601 format). For example, 2015-01-01T08:00:00.
    ///   - whatIfForecastArn: The Amazon Resource Name (ARN) of the what-if forecast to query.
    ///   - logger: Logger use during operation
    @inlinable
    public func queryWhatIfForecast(
        endDate: String? = nil,
        filters: [String: String],
        nextToken: String? = nil,
        startDate: String? = nil,
        whatIfForecastArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> QueryWhatIfForecastResponse {
        let input = QueryWhatIfForecastRequest(
            endDate: endDate, 
            filters: filters, 
            nextToken: nextToken, 
            startDate: startDate, 
            whatIfForecastArn: whatIfForecastArn
        )
        return try await self.queryWhatIfForecast(input, logger: logger)
    }
}

extension Forecastquery {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: Forecastquery, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
